package com.example;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;


@NoArgsConstructor
@AllArgsConstructor
@Data
public class Results
{


    /**
     * 返回码
     */
    private String statusCode;
    /**
     * 返回消息
     */
    private String statusMsg;
    /**
     * 请求的时间戳
     */
    private Long timestamp;
    /**
     * 返回请求内容
     */
    private Map<String, Object> resMap;

    public static Results success(Long timestamp) {
        return success(Contents.requestSuccess, Contents.getMsg4Code(Contents.requestSuccess), timestamp, null);
    }

    public static Results success(String statusMsg, Map<String, Object> resMap) {
        return success(Contents.requestSuccess, Contents.getMsg4Code(Contents.requestSuccess), System.currentTimeMillis(), resMap);
    }

    public static Results success(String statusMsg) {
        return success(Contents.requestSuccess, Contents.getMsg4Code(Contents.requestSuccess), System.currentTimeMillis(), null);
    }

    public static Results success(String statusCode, String statusMsg, Long timestamp, Map<String, Object> resMap) {
        return new Results(statusCode, statusMsg, timestamp, resMap);
    }

    public static Results fail(String statusCode, String statusMsg, Long timestamp, Map<String, Object> resMap) {
        Results results = new Results(statusCode, statusMsg, timestamp, resMap);
        return results;
    }

    public static Results requestFailMsg(Long timestamp, String msg) {
        return fail(Contents.requestFail, msg, timestamp, null);
    }

}
